package com.next

class Account
{
    String code
    String name

    AccountType type

    Boolean active = true

    String externalId

    Date createdDate = new Date()
    Date modifiedDate = new Date()

    static belongsTo = [parent: Account]

    Opportunity opportunity
    //订单

    Contact corporation
    //法人
    City city
    //城市
    District district
    //区县
    String registeredAddress
    //注册地址
    String officeAddress
    //办公地址
    Date firstOpenAccountDate
    //首次开立账户时间
    Double annualIncome
    //年收入
    Integer countOfBranch
    //分支机构数量
    String financialLicensingCode
    //金融许可证代码
    String higherAuthority
    //上级主管单位
    AccountLevel creditLevel
    //信用等级
    AccountEconomyType economyType
    //经济类型
    String email
    //公司email
    String englishName
    //公司英文名称
    Date evaluateDate
    //评估日期
    AccountLevel evaluateLevel
    //评估级别
    AccountFinanceReportType financeReportType
    //财务报表类型
    String financePhone
    //财务部可联系电话
    String fundSource
    //经费来源
    Boolean directorate
    //有无董事会
    Industry industry
    //国标行业分类
    Date registerDate
    //登记日期
    Date licenseStartTime
    //营业执照登记日期
    Date licenseEndTime
    //营业执照到期日期
    String licenseCode
    //营业执照代码

    String businessScope
    //经营范围
    String legalBusiness
    //合法经营情况
    String fax
    //传真
    String phone
    //联系电话
    Boolean privateEnterprise
    //民营企业
    CurrencyType currencyType
    //实收资本币种
    Boolean estateExploitation
    //是否从事房地产开发
    String enterpriseScale
    //企业规模
    String totalAssets
    //总资产
    String website
    //网站

    Boolean quotedCompany
    //公司是否上市
    String listedName
    //上市公司名称
    AccountListedType listedType
    //上市公司类型

    static constraints = {
        code maxSize: 128 //, unique: true
        code blank: true, nullable: true
        name maxSize: 64, unique: true

        parent blank: true, nullable: true

        externalId maxSize: 32, blank: true, nullable: true //, unique: true

        opportunity blank: true, nullable: true
        corporation blank: true, nullable: true
        city blank: true, nullable: true
        district blank: true, nullable: true
        registeredAddress maxSize: 256, blank: true, nullable: true
        officeAddress maxSize: 256, blank: true, nullable: true
        firstOpenAccountDate blank: true, nullable: true
        annualIncome blank: true, nullable: true
        countOfBranch blank: true, nullable: true
        financialLicensingCode blank: true, nullable: true, maxSize: 64
        higherAuthority blank: true, nullable: true, maxSize: 64
        creditLevel blank: true, nullable: true
        economyType blank: true, nullable: true
        email blank: true, nullable: true, maxSize: 64
        englishName blank: true, nullable: true, maxSize: 128
        evaluateDate blank: true, nullable: true
        evaluateLevel blank: true, nullable: true
        financeReportType blank: true, nullable: true
        financePhone blank: true, nullable: true, maxSize: 13
        fundSource blank: true, nullable: true, maxSize: 64
        directorate blank: true, nullable: true
        industry blank: true, nullable: true
        registerDate blank: true, nullable: true
        licenseStartTime blank: true, nullable: true
        licenseEndTime blank: true, nullable: true
        licenseCode blank: true, nullable: true, maxSize: 15
        businessScope blank: true, nullable: true, maxSize: 32
        legalBusiness blank: true, nullable: true, maxSize: 32
        fax blank: true, nullable: true, maxSize: 13
        phone blank: true, nullable: true, maxSize: 13
        privateEnterprise blank: true, nullable: true
        currencyType blank: true, nullable: true
        estateExploitation blank: true, nullable: true
        enterpriseScale blank: true, nullable: true, maxSize: 32
        totalAssets blank: true, nullable: true, maxSize: 32
        website blank: true, nullable: true, maxSize: 32

        quotedCompany blank: true, nullable: true
        listedName blank: true, nullable: true, maxSize: 64
        listedType blank: true, nullable: true

    }

    def beforeInsert()
    {
        if (!code)
        {
            code = UUID.randomUUID().toString()
        }
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
    }

    String toString()
    {
        name
    }
}
